package com.facedemo.bean;


import com.facedemo.MyApplication;
import com.facedemo.utils.SharePreferencesUtils;

public class DCamera {
    public int cameraId = 0;//摄像头ID
    public int displayOrientation = 90;//摄像头显示旋转角度
    public int cameraDataRotate = 90;//摄像头返回图像旋转角度
    public int cameraHeight = 480;//摄像头分辨率
    public int cameraWidth = 640;//摄像头分辨率
    public boolean isMirroring = true;//摄像头返回图像是否镜像

    public DCamera() {
        cameraId = SharePreferencesUtils.getInt(MyApplication.getInstance().getApplicationContext(),"cameraId",cameraId);;
        displayOrientation = SharePreferencesUtils.getInt(MyApplication.getInstance().getApplicationContext(),"display_orientation",displayOrientation);
        cameraDataRotate = SharePreferencesUtils.getInt(MyApplication.getInstance().getApplicationContext(),"data_rotate",cameraDataRotate);
        cameraWidth = SharePreferencesUtils.getInt(MyApplication.getInstance().getApplicationContext(),"camera_w",cameraWidth);
        cameraHeight = SharePreferencesUtils.getInt(MyApplication.getInstance().getApplicationContext(),"camera_h",cameraHeight);
        isMirroring = SharePreferencesUtils.getBoolean(MyApplication.getInstance().getApplicationContext(),"camera_mirroring",isMirroring);
    }

    public void saveCameraId(int id) {
        cameraId = id;
        SharePreferencesUtils.putInt(MyApplication.getInstance().getApplicationContext(),"cameraId",cameraId);
    }

    public void saveDisplayOrientation(int orientation) {
        displayOrientation = orientation;
        SharePreferencesUtils.putInt(MyApplication.getInstance().getApplicationContext(),"display_orientation",displayOrientation);
    }

    public void saveCameraDataRotate(int rotate) {
        cameraDataRotate = rotate;
        SharePreferencesUtils.putInt(MyApplication.getInstance().getApplicationContext(),"data_rotate",cameraDataRotate);
    }

    public void saveCameraHeight(int h) {
        cameraHeight = h;
        SharePreferencesUtils.putInt(MyApplication.getInstance().getApplicationContext(),"camera_h",cameraHeight);
    }

    public void saveCameraWidth(int w) {
        cameraWidth = w;
        SharePreferencesUtils.putInt(MyApplication.getInstance().getApplicationContext(),"camera_w",cameraWidth);
    }

    public void saveMirroring(boolean mirroring) {
        isMirroring = mirroring;
        SharePreferencesUtils.putBoolean(MyApplication.getInstance().getApplicationContext(),"camera_mirroring",mirroring);
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append(" cameraId=");
        sb.append(cameraId);
        sb.append(" displayOrientation=");
        sb.append(displayOrientation);
        sb.append(" cameraDataRotate=");
        sb.append(cameraDataRotate);
        sb.append(" cameraWidth=");
        sb.append(cameraWidth);
        sb.append(" cameraHeight=");
        sb.append(cameraHeight);
        return sb.toString();
    }
}
